<?php
/**
 * 借款预还管理
 */
namespace Admin\Controller\Borrow;
use Think\Controller;
use Admin\Controller\Common\BaseController;

class BorrowcancelController extends BaseController
{
	/**
	 *	管理后台菜单初始化与用户登录身份验证
	 */
//	public function _initialize()
//	{
//		session('facId','51');
//		// 判断用户是否登陆
//		if (!session('?facId'))
//		{
//			$url = 'http://' . $_SERVER['HTTP_HOST'] .'/tp_bypal/index.php';
//			redirect($url);
//			exit;
//		}
//	}


	/**
	 *	借款取消列表页
	 */
	public function borrowcancel_list() 
	{
//		$select_borrowNum = I("post.select_borrowNum","");
//		$select_custName = I("post.select_custName","");
//		$select_businessName = I("post.select_businessName","");
//
//		$search_array['select_borrowNum'] = $select_borrowNum;
//		$search_array['select_custName'] = $select_custName;
//		$search_array['select_businessName'] = $select_businessName;
//
//		$this->assign("search_array",$search_array);

//		$model_facilitator_trade = M('bypal_facilitator_trade');
//		$condition['tid'] = '8';
//		if ($select_borrowNum != '')
//		{
//			$condition['trade_contractnumber'] = array('like','%'.$select_borrowNum.'%');
//		}
//		if ($select_custName != '')
//		{
//			$model_cust_info = M('bypal_cust_info');
//			$condition_cust_info['cust_name'] = array('like','%'.$select_custName.'%');
//			$array_cust_info = $model_cust_info->where($condition_cust_info)->select();
//			$array_cust_info_exist = array('0');
//			foreach ($array_cust_info as $key => $value)
//			{
//				array_push($array_cust_info_exist, $value['cust_id']);
//			}
//			$condition['cid'] = array('in', $array_cust_info_exist);
//		}
//		if ($select_businessName != '')
//		{
//			$model_facilitator_info = M('bypal_facilitator_info');
//			$condition_facilitator_info['fac_simple_name'] = array('like','%'.$select_businessName.'%');
//			$array_facilitator_info = $model_facilitator_info->where($condition_facilitator_info)->select();
//			$array_facilitator_info_exist = array('0');
//			foreach ($array_facilitator_info as $key => $value)
//			{
//				array_push($array_facilitator_info_exist, $value['id']);
//			}
//			$condition['fid'] = array('in', $array_facilitator_info_exist);
//		}
//		$array_data = $model_facilitator_trade->where($condition)->order('trade_addtime desc')->select();
//		foreach ($array_data as $key => $value)
//		{
//			$array_data[$key]['trade_cancelask_time'] = date('Y-m-d H:i:s', $value['trade_cancelask_time']);
//
//			$model_cust_info = M('bypal_cust_info');
//			$data_cust_info = $model_cust_info->where('cust_id="'.$value['cid'].'"')->find();
//			$array_data[$key]['cust_name'] = $data_cust_info['cust_name'];
//
//			$model_facilitator_info = M('bypal_facilitator_info');
//			$data_facilitator_info = $model_facilitator_info->where('id="'.$value['fid'].'"')->find();
//			$array_data[$key]['fac_simple_name'] = $data_facilitator_info['fac_simple_name'];
//			$array_data[$key]['fac_phone'] = $data_facilitator_info['fac_phone'];
//
//			$model_factrade_state = M('bypal_factrade_state');
//			$data_factrade_state = $model_factrade_state->where('trade_id="'.$value['tid'].'"')->find();
//			$array_data[$key]['trade_name'] = $data_factrade_state['trade_name'];
//		}
//
//		$json_list = json_encode($array_data);
//		$this->assign('json_list',$json_list);

		$this->display();
	}

    public function borrowcancel_main(){
        $page=I("post.page","1");
        $rows=I("post.rows","10");
        $select_borrowNum = I("post.select_borrowNum","");
		$select_custName = I("post.select_custName","");
		$select_businessName = I("post.select_businessName","");

		$search_array['select_borrowNum'] = $select_borrowNum;
		$search_array['select_custName'] = $select_custName;
		$search_array['select_businessName'] = $select_businessName;

		$this->assign("search_array",$search_array);

        $borrow_info=D("Borrowinfo");
        $result=$borrow_info->select_borrow_cancel($search_array,$page,$rows);
        $json_list = json_encode($result);
        echo $json_list;
    }


}